package com.huawei.hwid.api.common;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.huawei.cloudservice.CloudRequestHandler;
import com.huawei.hwid.core.constants.HwAccountConstants;
import com.huawei.hwid.core.d.b.e;
import com.huawei.hwid.core.helper.handler.ErrorStatus;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;

class e$b extends SafeBroadcastReceiver {
    private Context a = null;
    private boolean b = false;
    private CloudRequestHandler c;

    public e$b(Context context, CloudRequestHandler cloudRequestHandler) {
        this.a = context;
        this.c = cloudRequestHandler;
    }

    public void onReceiveMsg(Context context, Intent intent) {
        if (!this.b) {
            try {
                Bundle bundle = new Bundle();
                bundle.putBoolean("LogoutBroadcastReceiver", true);
                e.a(this.a, bundle);
            } catch (IllegalArgumentException e) {
                e.c("CloudAccountImpl", "IllegalArgumentException", true);
            }
            this.b = true;
            if (intent != null) {
                String str = "";
                try {
                    str = intent.getAction();
                    e.d(context);
                    if (HwAccountConstants.ACTION_LOGOUT_CANCEL.equals(str)) {
                        if (this.c != null) {
                            this.c.onError(new ErrorStatus(3002, "logout hwid cancel: press cancel or back key"));
                            e.b("CloudAccountImpl", "logout hwid cancel: press cancel or back key", true);
                        }
                    } else if (HwAccountConstants.ACTION_LOGOUT_FAIL.equals(str) && this.c != null) {
                        this.c.onError(new ErrorStatus(19, "logout hwid failed"));
                        e.b("CloudAccountImpl", "logout hwid failed", true);
                    }
                } catch (Exception e2) {
                    e.d("CloudAccountImpl", "LogoutBroadcastReceiver param error", true);
                }
            }
        }
    }
}
